package com.cqc.jdk8.Jlang;

public class ThreadLocalTest {

    public static void main(String[] args) {
        ThreadLocal<String> threadLocal = new ThreadLocal<>();
        new Thread(() -> {
            threadLocal.set("value from t1");
            System.out.printf("t1,threadName:%s,value:%s%n", Thread.currentThread().getName(), threadLocal.get());
            threadLocal.remove();
        }).start();
        new Thread(() -> {
            threadLocal.set("value from t2");
            System.out.printf("t2,threadName:%s,value:%s%n", Thread.currentThread().getName(), threadLocal.get());
            threadLocal.remove();
        }).start();

        System.out.printf("main,threadName:%s,value:%s%n", Thread.currentThread().getName(), threadLocal.get());
    }
}
